package com.practice.book.mapper;

import com.practice.book.model.BookInfo;
import com.practice.book.model.PageRequest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-01-20
 * Time: 16:23
 */
@Mapper
public interface BookMapper {
    @Insert("insert into book_info (book_name,author,count,price,`status`,publish) values (#{bookName}," +
            "#{author},#{count},#{price},#{status},#{publish})")
    Integer insertBook(BookInfo bookInfo);

    @Select("select count(1) from book_info where status != 0")
    Integer count();

    @Select("select * from book_info where status != 0 order by id limit #{offset}, #{pageSize} ")
    List<BookInfo> queryBookByPage(PageRequest pageRequest);

    @Select("select * from book_info where id = #{bookId}")
    BookInfo queryBookById(Integer bookId);


    Integer updateBook(BookInfo bookInfo);


    void batchDelete(List<Integer> ids);
}
